package 最大公约数.找出数组的最大公约数;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: zcszdzdgys
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-08 16:44
 **/
public class zcszdzdgys {
    public static void main(String[] args) {
        int[] nums = {2,5,6,9,10};
        System.out.println(findGCD(nums));
    }
    public static int findGCD(int[] nums) {
        Arrays.sort(nums);
        return gcd(nums[0], nums[nums.length-1]);

    }
    public static int gcd(int a,int b){
        return b==0?a:gcd(b,a % b);
    }
}
